package com.usian.article.controller;

import com.usian.apis.article.ApArticleControllerApi;
import com.usian.article.service.ApArticleService;
import com.usian.model.article.dtos.ArticleHomeDto;
import com.usian.model.article.dtos.ArticleInfoDto;
import com.usian.model.article.pojos.ApArticle;
import com.usian.model.article.pojos.ApArticleConfig;
import com.usian.model.article.pojos.ApArticleContent;
import com.usian.model.common.dtos.ResponseResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController implements ApArticleControllerApi {
    @Autowired
    ApArticleService service;
    @Override
    @PostMapping("/saveArticle")
    public ApArticle save(@RequestBody ApArticle apArticle) {
        service.save(apArticle);
        return apArticle;
    }

    @Override
    @PostMapping("/saveConfig")
    public ApArticleConfig save(@RequestBody ApArticleConfig config) {
        return service.save(config);
    }

    @Override
    @PostMapping("/saveContennt")
    public ApArticleContent save(@RequestBody ApArticleContent content) {
        return service.save(content);
    }
    @PostMapping("/loadArticle")
    public ResponseResult loadArticle(@RequestBody ArticleHomeDto dto,@RequestParam Short type){
        return service.loadArticle(dto,type);
    }
    @PostMapping("/loadArticleInfo")
    private ResponseResult loadArticleInfo(@RequestBody ArticleInfoDto dto){
        return service.loadArticleInfo(dto);
    }
}
